
<%@page import="storeMovie.JavaBean.Order"%>
<%@page import="java.util.List"%>
<%@page import="storeMovie.Util.OrderManager"%>
<%@page import="java.sql.*"%><?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%
	String name = (String) session.getAttribute("userName");
	OrderManager manager = new OrderManager();
	List<Order> listOrders = manager.getOrderByUserName(name);
	
	if (listOrders.size() == 0) {
		out
				.println("<h1 style='text-align: center;font-size: large;'>You haven't ever bought our product</h1>");
	} else {
		out
				.println("<h1 style='text-align: center;font-size: large;'>Order History</h1><br/>");
		out
				.println("<h2 style='text-align: center;font-size: large;'>UserName:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
						+ name + "</h2>");
		out

				.println("<table width=100%' border='0' cellspacing='0' cellpadding='0'>");
		out.println("<tr align='center' bgcolor='red'>");
		out.println("<td width='40%'><strong>Order ID</strong></td>");
		out.println("<td width='20%'><strong>User Name</strong></td>");
		out.println("<td width='10%'><strong>Total Cost</strong></td>");
		out.println("<td width='20%'><strong>Order Date</strong></td>");
		out.println("</tr>");

		for (int i = 0; i < listOrders.size(); i++) {
			Order order = listOrders.get(i);
			if (i % 2 == 0) {
				out.println("<tr  align='center'>");
			} else {
				out.println("<tr align='center' bgcolor=#efefef>");
			}
			out.println("<td><a href='#' onclick='viewOrderDetail("
					+ order.getOrdeId()+ ")'>"
					+ order.getOrdeId() + "</a></td>");
			out.println("<td>" + order.getUserName()
					+ "</td>");
			out.println("<td>" + order.getTotal()+ "$</td>");
			out.println("<td>" + order.getDateOrder()
					+ "</td>");
		}
	}
%>